package com.tboss.template.home.controller;

import java.security.Principal;
import java.util.Locale;

import javax.servlet.http.HttpServletRequest;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;

import com.tboss.template.home.service.HomeService;

@Controller
@RequestMapping(value = "/template/home")
public class HomeController {
	
	@Autowired private HomeService homeService;
	
	@RequestMapping(value = {"/main"}, method = {RequestMethod.POST, RequestMethod.GET})//
	public String home(Locale locale, @RequestParam("sysCode") String sysCode, Model model, 
			Principal principal, HttpServletRequest req) {
		
		String rtnUrl = req.getServletPath().substring(1);
		
		this.homeService.home(locale, sysCode, model, principal);
		
		return rtnUrl+"Ajax";
	}
	
}
